﻿
namespace Codemonk.Common.Emit
{
    /// <summary>
    /// 访问器接口
    /// </summary>
    public interface ITypeAccessor
    {
        /// <summary>
        /// 创建对象的一个实例
        /// </summary>
        /// <param name="parameters">构造对象时的参数</param>
        /// <returns>一个对象实例</returns>
        object Create(params object[] parameters);
        /// <summary>
        /// 设置对象的属性值
        /// </summary>
        /// <param name="target">要设置的对象</param>
        /// <param name="name">属性名称</param>
        /// <param name="value">属性值</param>
        /// <returns>要设置的值</returns>
        void SetProperty(object target, string name, object value);
        /// <summary>
        /// 获取对象的属性值
        /// </summary>
        /// <param name="target">要获取的对象</param>
        /// <param name="name">属性名称</param>
        /// <returns>属性值</returns>
        object GetProperty(object target, string name);
        /// <summary>
        /// 执行对象的内的无返回值函数
        /// </summary>
        /// <param name="target">设置要执行的对象</param>
        /// <param name="name">要执行的函数</param>
        /// <param name="parameters">函数的参数</param>
        void ExecuteAction(object target, string name, params object[] parameters);
        /// <summary>
        /// 执行对象的内的有返回值函数
        /// </summary>
        /// <param name="target">设置要执行的对象</param>
        /// <param name="name">要执行的函数</param>
        /// <param name="parameters">函数的参数</param>
        /// <returns>函数的返回值</returns>
        object ExecuteFunc(object target, string name, params object[] parameters);
        /// <summary>
        /// 获取当前类型的可设置属性
        /// </summary>
        System.Collections.Generic.IEnumerable<string> SetterNames { get; }
        /// <summary>
        /// 获取当前类型的可获取属性
        /// </summary>
        System.Collections.Generic.IEnumerable<string> GetterNames { get; }
    }
}
